﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebComponents;
using WebComponents.Data;
using GBIT.Web;

public partial class ChiTietLienHe : UserControlBase {
  public string str = "";
  protected void Page_Load(object sender, EventArgs e) {
    this.Title = "Chi tiết liên hệ";
    int contactid = ConvertType.ToInt(Request.Params["id"]);
    ContactInfo contact = ContactController.GetByContactId(contactid);
    if (contact != null) {
      txtHoTen.Text = contact.Name;
      txtDiaChi.Text = contact.Address;
      txtContent.Text = contact.Content;
      txtChucVu.Text = contact.ChucVu;
      txtTieuDe.Text = contact.Title;
      txtCongTy.Text = contact.CompanyName;
      if (contact.CreatedDate.HasValue)
        txtCreateDate.Text = contact.CreatedDate.Value.ToShortDateString();
      txtTel.Text = contact.Tel;
      txtEmail.Text = contact.Email; //string.Format("<a href=\"?tabid=2&email={0}\">{1}</a>", contact.Email, contact.Email);            
      str = string.Format("?tabid=2&email={0}", contact.Email);
      contact.Status = 1;
      ContactController.Update(contact);
    }
    //this.SaveEnabled = true;
  }
  protected override void OnSaveRecord() {
    ContactInfo contact = ContactController.GetByContactId(ConvertType.ToInt(Request.Params["id"]));
    if (contact != null) {
      contact.Name = txtHoTen.Text;
      contact.Address = txtDiaChi.Text;
      contact.Content = txtContent.Text;
      contact.Tel = txtTel.Text;
      contact.Email = txtEmail.Text; //string.Format("<a href=\"?tabid=2&email={0}\">{1}</a>", contact.Email, contact.Email);
      ContactController.Update(contact);
    }
    WebComponents.Security.Security.ShowClientMessage(Page, "Cập nhật thông tin liên hệ thành công", "?tabid=8&cid=9");
  }
  protected void btnDelete_Click(object sender, EventArgs e) {
    ContactController.Delete(ConvertType.ToInt(Request.Params["id"]));
    WebComponents.Security.Security.ShowClientMessage(Page, "Xóa thông tin liên hệ thành công", "?tabid=8&cid=9");
  }
}
